'use strict';
import React, {Component} from 'react';
import {AsyncStorage, Alert} from "react-native"
import Toast from './ToastUtil'
/**
 * 对存储在内存里的变量进行操作
 */
'use strict';
module.exports = {
    /*
     保存全局变量
     */
    async saveStorage(key, datas) {
        AsyncStorage.setItem(key, datas, (error) => {
            let value = "保存数据成功："
            if (error) {
                value = "保存数据失败："
            }
        })

    },
    //读取全局存储数据
    async getNewStorageAllDataForKey(key) {
        try {
            let result = await AsyncStorage.getItem(key)
            return result
        } catch (error) {
            LOG("读取失败：" + error)
        }
    },


    //读取全局存储数据
    async getStorageAllDataForKey(key) {
        try {
            let result = await AsyncStorage.getItem(key)
            return JSON.parse(result)
        } catch (error) {
            LOG("读取失败：" + error)
        }

    },

    /*
     删除指定key的 全局变量
     */
    removeStroage(key) {
        AsyncStorage.removeItem(key, (error) => {
            let value = "删除数据成功："
            if (error) {
                value = "删除数据失败："
            }
            LOG(value)
        });
    }
};